package top.z.orm.handle.distribution.ds;

import top.z.orm.core.distribution.ds.Route;
import top.z.orm.handle.osql.core.HoneyConfig;

public class Router {

    private static Route route = null;

    private static String defaultDs;

    static {
        init();
    }

    private static void init() {
        int multiDsType = HoneyConfig.getHoneyConfig().multiDsType;
        defaultDs = HoneyConfig.getHoneyConfig().multiDsDefalutDS;
        if (multiDsType == 1) {
            route = new RwDs();
        } else if (multiDsType == 2) {
            route = new OnlyMultipleDB();
        }
    }

    public static String getDsName() {
        if (route == null) {
            return defaultDs;
        }
        return route.getDsName();
    }

    public static void refresh() {
        /*if (multiDsType == 1) {
            route = new RwDs();
        }*/
        // refresh all model
        init();
    }
}